package pers.liyan.shi.springcloud.config;

import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * mybatis 配置类
 * @author shily
 * @date 2019/5/22 14:45
 */
@MapperScan(basePackages = {"pers.liyan.shi.springcloud.mapper"})
@Configuration
public class MyBatisConfig {

    //自定义mybatis配置规则
    @Bean
    public ConfigurationCustomizer configurationCustomizer() {

        return new ConfigurationCustomizer() {
            @Override
            public void customize(org.apache.ibatis.session.Configuration configuration) {
                //开启驼峰命名法映射规则
                configuration.setMapUnderscoreToCamelCase(true);
                //开启二级缓存
                configuration.setCacheEnabled(true);

            }
        };
    }

}